<?php

namespace App\Modules\Home\Services;


use App\Modules\Home\Models\FoodsDetail;

class FoodsDetailService
{

    public static function getListByCats($params,$is_all = false) {
        $obj = FoodsDetail::orderBy('id')->where('status',1);
        if(isset($params['food_name'])&&$params['food_name']) {
            $obj->where('name','like','%'.$params['food_name'].'%');
        }
        if(isset($params['cat_id'])&&$params['cat_id']) {
            $obj->where('cat_id',$params['cat_id']);
        }
        if($is_all) {
            return $obj->get();
        }
        return $obj->paginate();
    }
}